# Maintainer: Andrea Zagli <andrea.zagli.free@gmail.com>

_realname=phodav
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=2.2
pkgrel=1
arch=('any')
pkgdesc="A WebDAV server using libsoup (mingw-w64)"
depends=("${MINGW_PACKAGE_PREFIX}-libsoup")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc"
             "gtk-doc")
options=('strip' 'staticlibs')
license=("LGPL 2.1")
url="https://www.gnome.org"
source=(https://download.gnome.org/sources/${_realname}/${pkgver}/${_realname}-$pkgver.tar.xz
        001-win.patch)
sha256sums=('080305dc9e804562f200ffc8c7d345c76754fce9cb01489dddb1b2c52c0557c1'
            '4e932ce9e7b01716aefe79f9cb78d26e200cdc9d28f6614eaa815df22fee104b')

prepare() {
  cd "${srcdir}"/${_realname}-${pkgver}

  patch -b -V simple -p1 -i ${srcdir}/001-win.patch

  autoreconf -isf
}

build() {
  mkdir -p build-${MINGW_CHOST}
  cd build-${MINGW_CHOST}

  mkdir -p doc/reference/html
  cp -rf ../${_realname}-${pkgver}/doc/reference/html/* doc/reference/html

  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --libexecdir=${MINGW_PREFIX}/lib \
    --host=${MINGW_CHOST} \
    --target=${MINGW_CHOST} \
    --build=${MINGW_CHOST}

  make
}

package() {
  cd "${srcdir}/build-${MINGW_CHOST}"
  make DESTDIR=${pkgdir} install

  install -Dm644 "${srcdir}/${_realname}-${pkgver}/COPYING" "${pkgdir}${MINGW_PREFIX}/share/licenses/lib${_realname}/COPYING"
}
